(self.webpackChunkmp_webgl = self.webpackChunkmp_webgl || []).push([
  [543],
  {
    91283: (e, t, r) => {
      "use strict";
      r.d(t, {
        Jk: () => s,
        br: () => n,
        yX: () => i,
        tE: () => o,
        ig: () => a,
      });
      const s = 0,
        n = 1,
        i = 2,
        o = 3,
        a = 4;
    },
    25543: (e, t, r) => {
      "use strict";
      r.d(t, { cj: () => DebugTilesRenderer, se: () => l });
      var s = r(2212);
      const n = {};
      var i = r(79554);
      const o = new s.Vector3(),
        a = ["x", "y", "z"];
      class SphereHelper extends s.LineSegments {
        constructor(e, t = 16776960, r = 40) {
          const n = new s.BufferGeometry(),
            i = [];
          for (let e = 0; e < 3; e++) {
            const t = a[e],
              s = a[(e + 1) % 3];
            o.set(0, 0, 0);
            for (let e = 0; e < r; e++) {
              let n;
              (n = (2 * Math.PI * e) / (r - 1)),
                (o[t] = Math.sin(n)),
                (o[s] = Math.cos(n)),
                i.push(o.x, o.y, o.z),
                (n = (2 * Math.PI * (e + 1)) / (r - 1)),
                (o[t] = Math.sin(n)),
                (o[s] = Math.cos(n)),
                i.push(o.x, o.y, o.z);
            }
          }
          n.setAttribute(
            "position",
            new s.BufferAttribute(new Float32Array(i), 3)
          ),
            n.computeBoundingSphere(),
            super(n, new s.LineBasicMaterial({ color: t, toneMapped: !1 })),
            (this.sphere = e),
            (this.type = "SphereHelper");
        }
        updateMatrixWorld(e) {
          const t = this.sphere;
          this.position.copy(t.center),
            this.scale.setScalar(t.radius),
            super.updateMatrixWorld(e);
        }
      }
      const l = Symbol("ORIGINAL_MATERIAL"),
        c = Symbol("HAS_RANDOM_COLOR"),
        h = Symbol("HAS_RANDOM_NODE_COLOR");
      function u() {}
      class DebugTilesRenderer extends i.I {
        constructor(...e) {
          super(...e);
          const t = this.group,
            r = new s.Group();
          (r.name = "DebugTilesRenderer.boxGroup"), t.add(r);
          const n = new s.Group();
          (n.name = "DebugTilesRenderer.sphereGroup"),
            t.add(n),
            (this.displayBoxBounds = !1),
            (this.displaySphereBounds = !1),
            (this.colorMode = 0),
            (this.customColorCallback = null),
            (this.boxGroup = r),
            (this.sphereGroup = n),
            (this.maxDebugDepth = -1),
            (this.maxDebugDistance = -1),
            (this.maxDebugError = -1),
            (this.getDebugColor = (e, t) => {
              t.setRGB(e, e, e);
            }),
            (this.extremeDebugDepth = -1),
            (this.extremeDebugError = -1);
        }
        initExtremes() {
          let e = -1;
          this.traverse((t) => {
            e = Math.max(e, t.__depth);
          });
          let t = -1;
          this.traverse((e) => {
            t = Math.max(t, e.geometricError);
          }),
            (this.extremeDebugDepth = e),
            (this.extremeDebugError = t);
        }
        fetchTileSet(...e) {
          const t = super.fetchTileSet(...e);
          return (
            t
              .then(() => {
                Promise.resolve().then(() => {
                  this.initExtremes();
                });
              })
              .catch(() => {}),
            t
          );
        }
        getTileInformationFromActiveObject(e) {
          let t = null;
          return (
            this.activeTiles.forEach((r) => {
              if (t) return !0;
              const s = r.cached.scene;
              s &&
                s.traverse((s) => {
                  s === e && (t = r);
                });
            }),
            t
              ? {
                  distanceToCamera: t.__distanceFromCamera,
                  geometricError: t.geometricError,
                  screenSpaceError: t.__error,
                  depth: t.__depth,
                  isLeaf: t.__isLeaf,
                }
              : null
          );
        }
        update() {
          if ((super.update(), !this.root)) return;
          (this.boxGroup.visible = this.displayBoxBounds),
            (this.sphereGroup.visible = this.displaySphereBounds);
          let e = -1;
          e =
            -1 === this.maxDebugDepth
              ? this.extremeDebugDepth
              : this.maxDebugDepth;
          let t = -1;
          t =
            -1 === this.maxDebugError
              ? this.extremeDebugError
              : this.maxDebugError;
          let r = -1;
          r =
            -1 === this.maxDebugDistance
              ? this.root.cached.sphere.radius
              : this.maxDebugDistance;
          const n = this.errorTarget,
            i = this.colorMode;
          this.visibleTiles.forEach((o) => {
            const a = o.cached.scene;
            let u, d, p;
            7 === i &&
              ((u = Math.random()),
              (d = 0.5 + 0.5 * Math.random()),
              (p = 0.375 + 0.25 * Math.random())),
              a.traverse((a) => {
                8 === i &&
                  ((u = Math.random()),
                  (d = 0.5 + 0.5 * Math.random()),
                  (p = 0.375 + 0.25 * Math.random()));
                const f = a.material;
                if (f) {
                  const m = a[l];
                  if (0 === i && f !== m)
                    a.material.dispose(), (a.material = a[l]);
                  else if (0 !== i && f === m)
                    if (a.isPoints) {
                      const e = new s.PointsMaterial();
                      (e.size = m.size),
                        (e.sizeAttenuation = m.sizeAttenuation),
                        (a.material = e);
                    } else
                      (a.material = new s.MeshStandardMaterial()),
                        (a.material.flatShading = !0);
                  switch (
                    (7 !== i && delete a.material[c],
                    8 !== i && delete a.material[h],
                    i)
                  ) {
                    case 4: {
                      const t = o.__depth / e;
                      this.getDebugColor(t, a.material.color);
                      break;
                    }
                    case 5: {
                      const t = o.__depthFromRenderedParent / e;
                      this.getDebugColor(t, a.material.color);
                      break;
                    }
                    case 1: {
                      const e = o.__error / n;
                      e > 1
                        ? a.material.color.setRGB(1, 0, 0)
                        : this.getDebugColor(e, a.material.color);
                      break;
                    }
                    case 2: {
                      const e = Math.min(o.geometricError / t, 1);
                      this.getDebugColor(e, a.material.color);
                      break;
                    }
                    case 3: {
                      const e = Math.min(o.__distanceFromCamera / r, 1);
                      this.getDebugColor(e, a.material.color);
                      break;
                    }
                    case 6:
                      o.children && 0 !== o.children.length
                        ? this.getDebugColor(0, a.material.color)
                        : this.getDebugColor(1, a.material.color);
                      break;
                    case 8:
                      a.material[h] ||
                        (a.material.color.setHSL(u, d, p),
                        (a.material[h] = !0));
                      break;
                    case 7:
                      a.material[c] ||
                        (a.material.color.setHSL(u, d, p),
                        (a.material[c] = !0));
                      break;
                    case 9:
                      this.customColorCallback
                        ? this.customColorCallback(o, a)
                        : console.warn(
                            "DebugTilesRenderer: customColorCallback not defined"
                          );
                  }
                }
              });
          });
        }
        setTileVisible(e, t) {
          super.setTileVisible(e, t);
          const r = e.cached,
            s = this.sphereGroup,
            n = this.boxGroup,
            i = r.boxHelperGroup,
            o = r.sphereHelper;
          t
            ? (i && (n.add(i), i.updateMatrixWorld(!0)),
              o && (s.add(o), o.updateMatrixWorld(!0)))
            : (i && n.remove(i), o && s.remove(o));
        }
        parseTile(e, t, r) {
          return super.parseTile(e, t, r).then(() => {
            const e = t.cached,
              r = e.scene;
            if (r) {
              if (e.box && e.boxTransform) {
                const r = e.box,
                  i = e.boxTransform,
                  o = new s.Group();
                (o.name = "DebugTilesRenderer.boxHelperGroup"),
                  o.matrix.copy(i),
                  (o.matrixAutoUpdate = !1);
                const a = new s.Box3Helper(
                  r,
                  (function (e) {
                    if (!n[e]) {
                      const t = Math.random(),
                        r = 0.5 + 0.5 * Math.random(),
                        i = 0.375 + 0.25 * Math.random();
                      n[e] = new s.Color().setHSL(t, r, i);
                    }
                    return n[e];
                  })(t.__depth)
                );
                (a.raycast = u),
                  o.add(a),
                  (e.boxHelperGroup = o),
                  this.visibleTiles.has(t) &&
                    this.displayBoxBounds &&
                    (this.boxGroup.add(o), o.updateMatrixWorld(!0));
              }
              if (e.sphere) {
                const r = e.sphere,
                  s = new SphereHelper(r);
                (s.raycast = u),
                  (e.sphereHelper = s),
                  this.visibleTiles.has(t) &&
                    this.displaySphereBounds &&
                    (this.sphereGroup.add(s), s.updateMatrixWorld(!0));
              }
              r.traverse((e) => {
                const t = e.material;
                t && (e[l] = t);
              });
            }
          });
        }
        disposeTile(e) {
          super.disposeTile(e);
          const t = e.cached;
          t.boxHelperGroup &&
            (t.boxHelperGroup.children[0].geometry.dispose(),
            delete t.boxHelperGroup),
            t.sphereHelper &&
              (t.sphereHelper.geometry.dispose(), delete t.sphereHelper);
        }
      }
    },
    79554: (e, t, r) => {
      "use strict";
      r.d(t, { I: () => TilesRenderer });
      var s = r(26470);
      class LRUCache {
        constructor() {
          (this.maxSize = 800),
            (this.minSize = 600),
            (this.unloadPercent = 0.05),
            (this.itemSet = new Map()),
            (this.itemList = []),
            (this.usedSet = new Set()),
            (this.callbacks = new Map()),
            (this.unloadPriorityCallback = null);
          const e = this.itemSet;
          this.defaultPriorityCallback = (t) => e.get(t);
        }
        isFull() {
          return this.itemSet.size >= this.maxSize;
        }
        add(e, t) {
          const r = this.itemSet;
          if (r.has(e)) return !1;
          if (this.isFull()) return !1;
          const s = this.usedSet,
            n = this.itemList,
            i = this.callbacks;
          return n.push(e), s.add(e), r.set(e, Date.now()), i.set(e, t), !0;
        }
        remove(e) {
          const t = this.usedSet,
            r = this.itemSet,
            s = this.itemList,
            n = this.callbacks;
          if (r.has(e)) {
            n.get(e)(e);
            const i = s.indexOf(e);
            return s.splice(i, 1), t.delete(e), r.delete(e), n.delete(e), !0;
          }
          return !1;
        }
        markUsed(e) {
          const t = this.itemSet,
            r = this.usedSet;
          t.has(e) && !r.has(e) && (t.set(e, Date.now()), r.add(e));
        }
        markAllUnused() {
          this.usedSet.clear();
        }
        unloadUnusedContent() {
          const e = this.unloadPercent,
            t = this.minSize,
            r = this.itemList,
            s = this.itemSet,
            n = this.usedSet,
            i = this.callbacks,
            o = r.length - n.size,
            a = r.length - t,
            l = this.unloadPriorityCallback || this.defaultPriorityCallback;
          if (a > 0 && o > 0) {
            r.sort((e, t) => {
              const r = n.has(e),
                s = n.has(t);
              return r && s ? 0 : r || s ? (r ? 1 : -1) : l(t) - l(e);
            });
            const c = Math.min(a, o),
              h = Math.max(t * e, c * e);
            let u = Math.min(h, o);
            u = Math.ceil(u);
            const d = r.splice(0, u);
            for (let e = 0, t = d.length; e < t; e++) {
              const t = d[e];
              i.get(t)(t), s.delete(t), i.delete(t);
            }
          }
        }
        scheduleUnload(e = !0) {
          var t;
          this.scheduled ||
            ((this.scheduled = !0),
            (t = () => {
              (this.scheduled = !1),
                this.unloadUnusedContent(),
                e && this.markAllUnused();
            }),
            Promise.resolve().then(t));
        }
      }
      class PriorityQueue {
        constructor() {
          (this.maxJobs = 6),
            (this.items = []),
            (this.callbacks = new Map()),
            (this.currJobs = 0),
            (this.scheduled = !1),
            (this.autoUpdate = !0),
            (this.priorityCallback = () => {
              throw new Error(
                "PriorityQueue: PriorityCallback function not defined."
              );
            });
        }
        sort() {
          const e = this.priorityCallback;
          this.items.sort(e);
        }
        add(e, t) {
          return new Promise((r, s) => {
            const n = this.items,
              i = this.callbacks;
            n.push(e),
              i.set(e, (...e) =>
                t(...e)
                  .then(r)
                  .catch(s)
              ),
              this.autoUpdate && this.scheduleJobRun();
          });
        }
        remove(e) {
          const t = this.items,
            r = this.callbacks,
            s = t.indexOf(e);
          -1 !== s && (t.splice(s, 1), r.delete(e));
        }
        tryRunJobs() {
          this.sort();
          const e = this.items,
            t = this.callbacks,
            r = this.maxJobs;
          let s = this.currJobs;
          for (; r > s && e.length > 0; ) {
            s++;
            const r = e.pop(),
              n = t.get(r);
            t.delete(r),
              n(r)
                .then(() => {
                  this.currJobs--, this.autoUpdate && this.scheduleJobRun();
                })
                .catch(() => {
                  this.currJobs--, this.autoUpdate && this.scheduleJobRun();
                });
          }
          this.currJobs = s;
        }
        scheduleJobRun() {
          this.scheduled ||
            (requestAnimationFrame(() => {
              this.tryRunJobs(), (this.scheduled = !1);
            }),
            (this.scheduled = !0));
        }
      }
      var n = r(91283);
      function i(e) {
        return e === n.tE || e === n.ig;
      }
      function o(e, t) {
        return e.__lastFrameVisited === t && e.__used;
      }
      function a(e, t) {
        e.__lastFrameVisited !== t &&
          ((e.__lastFrameVisited = t),
          (e.__used = !1),
          (e.__inFrustum = !1),
          (e.__isLeaf = !1),
          (e.__visible = !1),
          (e.__active = !1),
          (e.__error = 1 / 0),
          (e.__distanceFromCamera = 1 / 0),
          (e.__childrenWereVisible = !1),
          (e.__allChildrenLoaded = !1));
      }
      function l(e, t, r) {
        if ((a(e, t), (e.__used = !0), r.markUsed(e), e.__contentEmpty)) {
          const s = e.children;
          for (let e = 0, n = s.length; e < n; e++) l(s[e], t, r);
        }
      }
      function c(e, t, r) {
        if (e.__contentEmpty && (!e.__externalTileSet || i(e.__loadingState))) {
          const s = e.children;
          for (let e = 0, n = s.length; e < n; e++) {
            const n = s[e];
            (n.__depthFromRenderedParent = t), c(n, t, r);
          }
        } else r.requestTileContents(e);
      }
      function h(e, t = null, r = null, s = null, n = 0) {
        if (t && t(e, s, n)) return void (r && r(e, s, n));
        const i = e.children;
        for (let s = 0, o = i.length; s < o; s++) h(i[s], t, r, e, n + 1);
        r && r(e, s, n);
      }
      function u(e, t) {
        const r = t.stats,
          s = t.frameCount,
          n = t.errorTarget,
          i = t.maxDepth,
          o = t.loadSiblings,
          c = t.lruCache,
          h = t.stopAtEmptyTiles;
        a(e, s);
        if (!1 === t.tileInView(e)) return !1;
        if (
          ((e.__used = !0),
          c.markUsed(e),
          (e.__inFrustum = !0),
          r.inFrustum++,
          (h || !e.__contentEmpty) && !e.__externalTileSet)
        ) {
          t.calculateError(e);
          if (e.__error <= n) return !0;
          if (t.maxDepth > 0 && e.__depth + 1 >= i) return !0;
        }
        let d = !1;
        const p = e.children;
        for (let e = 0, r = p.length; e < r; e++) {
          const r = u(p[e], t);
          d = d || r;
        }
        if (d && o)
          for (let e = 0, t = p.length; e < t; e++) {
            l(p[e], s, c);
          }
        return !0;
      }
      function d(e, t) {
        const r = t.stats,
          s = t.frameCount;
        if (!o(e, s)) return;
        r.used++;
        const a = e.children;
        let l = !1;
        for (let e = 0, t = a.length; e < t; e++) {
          const t = a[e];
          l = l || o(t, s);
        }
        if (l) {
          let r = !1,
            l = !0;
          for (let e = 0, c = a.length; e < c; e++) {
            const c = a[e];
            if (
              (d(c, t),
              (r = r || c.__wasSetVisible || c.__childrenWereVisible),
              o(c, s))
            ) {
              const e =
                c.__allChildrenLoaded ||
                (!c.__contentEmpty && i(c.__loadingState)) ||
                (c.__externalTileSet && c.__loadingState === n.ig);
              l = l && e;
            }
          }
          (e.__childrenWereVisible = r), (e.__allChildrenLoaded = l);
        } else e.__isLeaf = !0;
      }
      function p(e, t) {
        const r = t.stats,
          s = t.frameCount;
        if (!o(e, s)) return;
        const a = e.parent,
          l = a ? a.__depthFromRenderedParent : -1;
        e.__depthFromRenderedParent = l;
        const h = t.lruCache;
        if (e.__isLeaf)
          return (
            e.__depthFromRenderedParent++,
            void (e.__loadingState === n.tE
              ? (e.__inFrustum && ((e.__visible = !0), r.visible++),
                (e.__active = !0),
                r.active++)
              : h.isFull() ||
                (e.__contentEmpty && !e.__externalTileSet) ||
                t.requestTileContents(e))
          );
        const u = (t.errorTarget + 1) * t.errorThreshold,
          d = e.__error <= u,
          f = d || "ADD" === e.refine,
          m = !e.__contentEmpty,
          g = m || e.__externalTileSet,
          _ = i(e.__loadingState) && g,
          b = e.__childrenWereVisible,
          T = e.children;
        let x = e.__allChildrenLoaded;
        if (
          (f && m && e.__depthFromRenderedParent++,
          f && !_ && !h.isFull() && g && t.requestTileContents(e),
          ((d && !x && !b && _) || ("ADD" === e.refine && _)) &&
            (e.__inFrustum && ((e.__visible = !0), r.visible++),
            (e.__active = !0),
            r.active++),
          "ADD" !== e.refine && d && !x && _)
        )
          for (let r = 0, n = T.length; r < n; r++) {
            const n = T[r];
            o(n, s) &&
              !h.isFull() &&
              ((n.__depthFromRenderedParent = e.__depthFromRenderedParent + 1),
              c(n, n.__depthFromRenderedParent, t));
          }
        else
          for (let e = 0, r = T.length; e < r; e++) {
            const r = T[e];
            o(r, s) && p(r, t);
          }
      }
      function f(e, t) {
        const r = o(e, t.frameCount);
        if (r || e.__usedLastFrame) {
          let s = !1,
            i = !1;
          r &&
            ((s = e.__active),
            (i = (t.displayActiveTiles && e.__active) || e.__visible)),
            e.__contentEmpty ||
              e.__loadingState !== n.tE ||
              (e.__wasSetActive !== s && t.setTileActive(e, s),
              e.__wasSetVisible !== i && t.setTileVisible(e, i)),
            (e.__wasSetActive = s),
            (e.__wasSetVisible = i),
            (e.__usedLastFrame = r);
          const o = e.children;
          for (let e = 0, r = o.length; e < r; e++) {
            f(o[e], t);
          }
        }
      }
      const m = (e, t) =>
          e.__depth !== t.__depth
            ? e.__depth > t.__depth
              ? -1
              : 1
            : e.__inFrustum !== t.__inFrustum
            ? e.__inFrustum
              ? 1
              : -1
            : e.__used !== t.__used
            ? e.__used
              ? 1
              : -1
            : e.__error !== t.__error
            ? e.__error > t.__error
              ? 1
              : -1
            : e.__distanceFromCamera !== t.__distanceFromCamera
            ? e.__distanceFromCamera > t.__distanceFromCamera
              ? -1
              : 1
            : 0,
        g = (e) => 1 / (e.__depthFromRenderedParent + 1);
      function _(e) {
        return new TextDecoder().decode(e);
      }
      class FeatureTable {
        constructor(e, t, r, s) {
          (this.buffer = e), (this.binOffset = t + r), (this.binLength = s);
          let n = null;
          if (0 !== r) {
            const s = new Uint8Array(e, t, r);
            n = JSON.parse(_(s));
          } else n = {};
          this.header = n;
        }
        getKeys() {
          return Object.keys(this.header);
        }
        getData(e, t, r = null, s = null) {
          const n = this.header;
          if (!(e in n)) return null;
          const i = n[e];
          if (i instanceof Object) {
            if (Array.isArray(i)) return i;
            {
              const { buffer: n, binOffset: o, binLength: a } = this,
                l = i.byteOffset || 0,
                c = i.type || s,
                h = i.componentType || r;
              if ("type" in i && s && i.type !== s)
                throw new Error(
                  "FeatureTable: Specified type does not match expected type."
                );
              let u, d;
              switch (c) {
                case "SCALAR":
                  u = 1;
                  break;
                case "VEC2":
                  u = 2;
                  break;
                case "VEC3":
                  u = 3;
                  break;
                case "VEC4":
                  u = 4;
                  break;
                default:
                  throw new Error(
                    `FeatureTable : Feature type not provided for "${e}".`
                  );
              }
              const p = o + l,
                f = t * u;
              switch (h) {
                case "BYTE":
                  d = new Int8Array(n, p, f);
                  break;
                case "UNSIGNED_BYTE":
                  d = new Uint8Array(n, p, f);
                  break;
                case "SHORT":
                  d = new Int16Array(n, p, f);
                  break;
                case "UNSIGNED_SHORT":
                  d = new Uint16Array(n, p, f);
                  break;
                case "INT":
                  d = new Int32Array(n, p, f);
                  break;
                case "UNSIGNED_INT":
                  d = new Uint32Array(n, p, f);
                  break;
                case "FLOAT":
                  d = new Float32Array(n, p, f);
                  break;
                case "DOUBLE":
                  d = new Float64Array(n, p, f);
                  break;
                default:
                  throw new Error(
                    `FeatureTable : Feature component type not provided for "${e}".`
                  );
              }
              if (p + f * d.BYTES_PER_ELEMENT > o + a)
                throw new Error(
                  "FeatureTable: Feature data read outside binary body length."
                );
              return d;
            }
          }
          return i;
        }
      }
      class BatchTable extends FeatureTable {
        constructor(e, t, r, s, n) {
          super(e, r, s, n), (this.batchSize = t);
        }
        getData(e, t = null, r = null) {
          return super.getData(e, this.batchSize, r, t);
        }
      }
      var b = r(2212),
        T = r(17047);
      class B3DMLoader extends class B3DMLoaderBase {
        constructor() {
          (this.fetchOptions = {}), (this.workingPath = "");
        }
        load(e) {
          return fetch(e, this.fetchOptions)
            .then((t) => {
              if (!t.ok)
                throw new Error(
                  `Failed to load file "${e}" with status ${t.status} : ${t.statusText}`
                );
              return t.arrayBuffer();
            })
            .then((t) => {
              if ("" === this.workingPath) {
                const t = e.split(/\\\//g);
                t.pop(), (this.workingPath = t.join("/"));
              }
              return this.parse(t);
            });
        }
        parse(e) {
          const t = new DataView(e),
            r =
              String.fromCharCode(t.getUint8(0)) +
              String.fromCharCode(t.getUint8(1)) +
              String.fromCharCode(t.getUint8(2)) +
              String.fromCharCode(t.getUint8(3));
          console.assert("b3dm" === r);
          const s = t.getUint32(4, !0);
          console.assert(1 === s);
          const n = t.getUint32(8, !0);
          console.assert(n === e.byteLength);
          const i = t.getUint32(12, !0),
            o = t.getUint32(16, !0),
            a = t.getUint32(20, !0),
            l = t.getUint32(24, !0),
            c = e.slice(28, 28 + i + o),
            h = new FeatureTable(c, 0, i, o),
            u = 28 + i + o,
            d = e.slice(u, u + a + l),
            p = new BatchTable(d, h.getData("BATCH_LENGTH"), 0, a, l),
            f = u + a + l;
          return {
            version: s,
            featureTable: h,
            batchTable: p,
            glbBytes: new Uint8Array(e, f, n - f),
          };
        }
      } {
        constructor(e = b.DefaultLoadingManager) {
          super(), (this.manager = e);
        }
        parse(e) {
          const t = super.parse(e),
            r = t.glbBytes.slice().buffer;
          return new Promise((e, s) => {
            const n = this.manager,
              i = this.fetchOptions,
              o = n.getHandler("path.gltf") || new T.GLTFLoader(n);
            "include" === i.credentials &&
              "cors" === i.mode &&
              o.setCrossOrigin("use-credentials"),
              "credentials" in i &&
                o.setWithCredentials("include" === i.credentials),
              i.headers && o.setRequestHeader(i.headers);
            let a = this.workingPath;
            /[\\/]$/.test(a) || (a += "/"),
              o.parse(
                r,
                a,
                (r) => {
                  const { batchTable: s, featureTable: n } = t,
                    { scene: i } = r,
                    o = n.getData("RTC_CENTER");
                  o &&
                    ((i.position.x += o[0]),
                    (i.position.y += o[1]),
                    (i.position.z += o[2])),
                    (r.batchTable = s),
                    (r.featureTable = n),
                    (i.batchTable = s),
                    (i.featureTable = n),
                    e(r);
                },
                s
              );
          });
        }
      }
      class PNTSLoader extends class PNTSLoaderBase {
        constructor() {
          this.fetchOptions = {};
        }
        load(e) {
          return fetch(e, this.fetchOptions)
            .then((t) => {
              if (!t.ok)
                throw new Error(
                  `Failed to load file "${e}" with status ${t.status} : ${t.statusText}`
                );
              return t.arrayBuffer();
            })
            .then((e) => this.parse(e));
        }
        parse(e) {
          const t = new DataView(e),
            r =
              String.fromCharCode(t.getUint8(0)) +
              String.fromCharCode(t.getUint8(1)) +
              String.fromCharCode(t.getUint8(2)) +
              String.fromCharCode(t.getUint8(3));
          console.assert("pnts" === r);
          const s = t.getUint32(4, !0);
          console.assert(1 === s);
          const n = t.getUint32(8, !0);
          console.assert(n === e.byteLength);
          const i = t.getUint32(12, !0),
            o = t.getUint32(16, !0),
            a = t.getUint32(20, !0),
            l = t.getUint32(24, !0),
            c = e.slice(28, 28 + i + o),
            h = new FeatureTable(c, 0, i, o),
            u = 28 + i + o,
            d = e.slice(u, u + a + l),
            p = new BatchTable(
              d,
              h.getData("BATCH_LENGTH") || h.getData("POINTS_LENGTH"),
              0,
              a,
              l
            );
          return { version: s, featureTable: h, batchTable: p };
        }
      } {
        constructor(e = b.DefaultLoadingManager) {
          super(), (this.manager = e);
        }
        parse(e) {
          const t = super.parse(e),
            { featureTable: r } = t,
            s = r.getData("POINTS_LENGTH"),
            n = r.getData("POSITION", s, "FLOAT", "VEC3"),
            i = r.getData("RGB", s, "UNSIGNED_BYTE", "VEC3");
          [
            "RTC_CENTER",
            "QUANTIZED_VOLUME_OFFSET",
            "QUANTIZED_VOLUME_SCALE",
            "CONSTANT_RGBA",
            "BATCH_LENGTH",
            "POSITION_QUANTIZED",
            "RGBA",
            "RGB565",
            "NORMAL",
            "NORMAL_OCT16P",
          ].forEach((e) => {
            e in r.header &&
              console.warn(
                `PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`
              );
          });
          const o = new b.BufferGeometry();
          o.setAttribute("position", new b.BufferAttribute(n, 3, !1));
          const a = new b.PointsMaterial();
          (a.size = 2),
            (a.sizeAttenuation = !1),
            null !== i &&
              (o.setAttribute("color", new b.BufferAttribute(i, 3, !0)),
              (a.vertexColors = !0));
          const l = new b.Points(o, a);
          (t.scene = l), (t.scene.featureTable = r);
          const c = r.getData("RTC_CENTER");
          return (
            c &&
              ((t.scene.position.x += c[0]),
              (t.scene.position.y += c[1]),
              (t.scene.position.z += c[2])),
            t
          );
        }
      }
      const x = new b.Vector3(),
        w = new b.Vector3(),
        C = new b.Vector3(),
        y = new b.Vector3(),
        S = new b.Quaternion(),
        v = new b.Vector3(),
        M = new b.Matrix4();
      class I3DMLoader extends class I3DMLoaderBase {
        constructor() {
          (this.fetchOptions = {}), (this.workingPath = "");
        }
        resolveExternalURL(e) {
          return /^[^\\/]/.test(e) ? this.workingPath + "/" + e : e;
        }
        load(e) {
          return fetch(e, this.fetchOptions)
            .then((t) => {
              if (!t.ok)
                throw new Error(
                  `Failed to load file "${e}" with status ${t.status} : ${t.statusText}`
                );
              return t.arrayBuffer();
            })
            .then((t) => {
              if ("" === this.workingPath) {
                const t = e.split(/\\\//g);
                t.pop(), (this.workingPath = t.join("/"));
              }
              return this.parse(t);
            });
        }
        parse(e) {
          const t = new DataView(e),
            r =
              String.fromCharCode(t.getUint8(0)) +
              String.fromCharCode(t.getUint8(1)) +
              String.fromCharCode(t.getUint8(2)) +
              String.fromCharCode(t.getUint8(3));
          console.assert("i3dm" === r);
          const s = t.getUint32(4, !0);
          console.assert(1 === s);
          const n = t.getUint32(8, !0);
          console.assert(n === e.byteLength);
          const i = t.getUint32(12, !0),
            o = t.getUint32(16, !0),
            a = t.getUint32(20, !0),
            l = t.getUint32(24, !0),
            c = t.getUint32(28, !0),
            h = e.slice(32, 32 + i + o),
            u = new FeatureTable(h, 0, i, o),
            d = 32 + i + o,
            p = e.slice(d, d + a + l),
            f = new BatchTable(p, u.getData("INSTANCES_LENGTH"), 0, a, l),
            m = d + a + l,
            g = new Uint8Array(e, m, n - m);
          let b = null,
            T = null;
          if (c) (b = g), (T = Promise.resolve());
          else {
            const e = this.resolveExternalURL(_(g));
            T = fetch(e, this.fetchOptions)
              .then((t) => {
                if (!t.ok)
                  throw new Error(
                    `I3DMLoaderBase : Failed to load file "${e}" with status ${t.status} : ${t.statusText}`
                  );
                return t.arrayBuffer();
              })
              .then((e) => {
                b = new Uint8Array(e);
              });
          }
          return T.then(() => ({
            version: s,
            featureTable: u,
            batchTable: f,
            glbBytes: b,
          }));
        }
      } {
        constructor(e = b.DefaultLoadingManager) {
          super(), (this.manager = e);
        }
        resolveExternalURL(e) {
          return this.manager.resolveURL(super.resolveExternalURL(e));
        }
        parse(e) {
          return super.parse(e).then((e) => {
            const { featureTable: t, batchTable: r } = e,
              s = e.glbBytes.slice().buffer;
            return new Promise((e, n) => {
              const i = this.fetchOptions,
                o = this.manager,
                a = o.getHandler("path.gltf") || new T.GLTFLoader(o);
              "include" === i.credentials &&
                "cors" === i.mode &&
                a.setCrossOrigin("use-credentials"),
                "credentials" in i &&
                  a.setWithCredentials("include" === i.credentials),
                i.headers && a.setRequestHeader(i.headers);
              let l = this.workingPath;
              /[\\/]$/.test(l) || (l += "/"),
                a.parse(
                  s,
                  l,
                  (s) => {
                    const n = t.getData("INSTANCES_LENGTH"),
                      i = t.getData("POSITION", n, "FLOAT", "VEC3"),
                      o = t.getData("NORMAL_UP", n, "FLOAT", "VEC3"),
                      a = t.getData("NORMAL_RIGHT", n, "FLOAT", "VEC3"),
                      l = t.getData("SCALE_NON_UNIFORM", n, "FLOAT", "VEC3"),
                      c = t.getData("SCALE", n, "FLOAT", "SCALAR");
                    [
                      "RTC_CENTER",
                      "QUANTIZED_VOLUME_OFFSET",
                      "QUANTIZED_VOLUME_SCALE",
                      "EAST_NORTH_UP",
                      "POSITION_QUANTIZED",
                      "NORMAL_UP_OCT32P",
                      "NORMAL_RIGHT_OCT32P",
                    ].forEach((e) => {
                      e in t.header &&
                        console.warn(
                          `I3DMLoader: Unsupported FeatureTable feature "${e}" detected.`
                        );
                    });
                    const h = new Map(),
                      u = [];
                    s.scene.traverse((e) => {
                      if (e.isMesh) {
                        const { geometry: t, material: r } = e,
                          s = new b.InstancedMesh(t, r, n);
                        s.position.copy(e.position),
                          s.rotation.copy(e.rotation),
                          s.scale.copy(e.scale),
                          u.push(s),
                          h.set(e, s);
                      }
                    });
                    const d = new b.Vector3();
                    for (let e = 0; e < n; e++)
                      (d.x += i[3 * e + 0] / n),
                        (d.y += i[3 * e + 1] / n),
                        (d.z += i[3 * e + 2] / n);
                    h.forEach((e, t) => {
                      const r = t.parent;
                      r &&
                        (r.remove(t),
                        r.add(e),
                        e.updateMatrixWorld(),
                        e.position.copy(d).applyMatrix4(e.matrixWorld));
                    });
                    for (let e = 0; e < n; e++) {
                      y.set(
                        i[3 * e + 0] - d.x,
                        i[3 * e + 1] - d.y,
                        i[3 * e + 2] - d.z
                      ),
                        o
                          ? (w.set(o[3 * e + 0], o[3 * e + 1], o[3 * e + 2]),
                            C.set(a[3 * e + 0], a[3 * e + 1], a[3 * e + 2]),
                            x.crossVectors(C, w).normalize(),
                            M.makeBasis(C, w, x),
                            S.setFromRotationMatrix(M))
                          : S.set(0, 0, 0, 1),
                        c
                          ? v.setScalar(c[e])
                          : l
                          ? v.set(l[3 * e + 0], l[3 * e + 1], l[3 * e + 2])
                          : v.set(1, 1, 1),
                        M.compose(y, S, v);
                      for (let t = 0, r = u.length; t < r; t++) {
                        u[t].setMatrixAt(e, M);
                      }
                    }
                    (s.batchTable = r),
                      (s.featureTable = t),
                      (s.scene.batchTable = r),
                      (s.scene.featureTable = t),
                      e(s);
                  },
                  n
                );
            });
          });
        }
      }
      class CMPTLoader extends class CMPTLoaderBase {
        constructor() {
          (this.fetchOptions = {}), (this.workingPath = "");
        }
        load(e) {
          return fetch(e, this.fetchOptions)
            .then((t) => {
              if (!t.ok)
                throw new Error(
                  `Failed to load file "${e}" with status ${t.status} : ${t.statusText}`
                );
              return t.arrayBuffer();
            })
            .then((t) => {
              if ("" === this.workingPath) {
                const t = e.split(/\\\//g);
                t.pop(), (this.workingPath = t.join("/"));
              }
              return this.parse(t);
            });
        }
        parse(e) {
          const t = new DataView(e),
            r =
              String.fromCharCode(t.getUint8(0)) +
              String.fromCharCode(t.getUint8(1)) +
              String.fromCharCode(t.getUint8(2)) +
              String.fromCharCode(t.getUint8(3));
          console.assert(
            "cmpt" === r,
            'CMPTLoader: The magic bytes equal "cmpt".'
          );
          const s = t.getUint32(4, !0);
          console.assert(
            1 === s,
            'CMPTLoader: The version listed in the header is "1".'
          );
          const n = t.getUint32(8, !0);
          console.assert(
            n === e.byteLength,
            "CMPTLoader: The contents buffer length listed in the header matches the file."
          );
          const i = t.getUint32(12, !0),
            o = [];
          let a = 16;
          for (let t = 0; t < i; t++) {
            const t = new DataView(e, a, 12),
              r =
                String.fromCharCode(t.getUint8(0)) +
                String.fromCharCode(t.getUint8(1)) +
                String.fromCharCode(t.getUint8(2)) +
                String.fromCharCode(t.getUint8(3)),
              s = t.getUint32(4, !0),
              n = t.getUint32(8, !0),
              i = new Uint8Array(e, a, n);
            o.push({ type: r, buffer: i, version: s }), (a += n);
          }
          return { version: s, tiles: o };
        }
      } {
        constructor(e = b.DefaultLoadingManager) {
          super(), (this.manager = e);
        }
        parse(e) {
          const t = super.parse(e),
            r = this.manager,
            s = [];
          for (const e in t.tiles) {
            const { type: n, buffer: i } = t.tiles[e];
            switch (n) {
              case "b3dm": {
                const e = i.slice(),
                  t = new B3DMLoader(r);
                (t.workingPath = this.workingPath),
                  (t.fetchOptions = this.fetchOptions);
                const n = t.parse(e.buffer);
                s.push(n);
                break;
              }
              case "pnts": {
                const e = i.slice(),
                  t = new PNTSLoader(r).parse(e.buffer),
                  n = Promise.resolve(t);
                s.push(n);
                break;
              }
              case "i3dm": {
                const e = i.slice(),
                  t = new I3DMLoader(r);
                (t.workingPath = this.workingPath),
                  (t.fetchOptions = this.fetchOptions);
                const n = t.parse(e.buffer);
                s.push(n);
                break;
              }
            }
          }
          return Promise.all(s).then((e) => {
            const t = new b.Group();
            return (
              e.forEach((e) => {
                t.add(e.scene);
              }),
              { tiles: e, scene: t }
            );
          });
        }
      }
      class CustomTileParser {
        constructor(e = b.DefaultLoadingManager, t = "") {
          (this.manager = e), (this.extension = `path.${t || "unknown"}`);
        }
        parse(e) {
          const t = this.manager,
            r = this.extension;
          return new Promise((s, n) => {
            t.getHandler(r).parse(
              e,
              null,
              (e) => {
                s(e);
              },
              n
            );
          });
        }
      }
      const L = new b.Matrix4();
      class TilesGroup extends b.Group {
        constructor(e) {
          super(),
            (this.name = "TilesRenderer.TilesGroup"),
            (this.tilesRenderer = e);
        }
        raycast(e, t) {
          this.tilesRenderer.optimizeRaycast &&
            this.tilesRenderer.raycast(e, t);
        }
        updateMatrixWorld(e) {
          if (
            (this.matrixAutoUpdate && this.updateMatrix(),
            this.matrixWorldNeedsUpdate || e)
          ) {
            null === this.parent
              ? L.copy(this.matrix)
              : L.multiplyMatrices(this.parent.matrixWorld, this.matrix),
              (this.matrixWorldNeedsUpdate = !1);
            const e = L.elements,
              t = this.matrixWorld.elements;
            let r = !1;
            for (let s = 0; s < 16; s++) {
              const n = e[s],
                i = t[s];
              if (Math.abs(n - i) > Number.EPSILON) {
                r = !0;
                break;
              }
            }
            if (r) {
              this.matrixWorld.copy(L);
              const e = this.children;
              for (let t = 0, r = e.length; t < r; t++)
                e[t].updateMatrixWorld();
            }
          }
        }
      }
      const A = new b.Sphere(),
        E = new b.Matrix4(),
        R = new b.Vector3(),
        D = new b.Vector3(),
        U = new b.Ray(),
        P = [];
      function k(e, t) {
        return e.distance - t.distance;
      }
      function O(e, t, r) {
        e.traverse((e) => {
          Object.getPrototypeOf(e).raycast.call(e, t, r);
        });
      }
      function F(e, t, r, s) {
        if (r.has(e)) {
          if ((O(e.cached.scene, s, P), P.length > 0)) {
            P.length > 1 && P.sort(k);
            const e = P[0];
            return (P.length = 0), e;
          }
          return null;
        }
        const n = [],
          i = e.children;
        for (let e = 0, r = i.length; e < r; e++) {
          const r = i[e],
            o = r.cached,
            a = t.matrixWorld;
          E.copy(a);
          const l = o.sphere;
          if (l && (A.copy(l), A.applyMatrix4(E), !s.ray.intersectsSphere(A)))
            continue;
          const c = o.box,
            h = o.boxTransform;
          if (c) {
            if (
              (E.multiply(h).invert(),
              U.copy(s.ray),
              U.applyMatrix4(E),
              !U.intersectBox(c, R))
            )
              continue;
            {
              let e;
              D.setFromMatrixScale(E),
                (e = D.x),
                Math.abs(Math.max(D.x - D.y, D.x - D.z)) > 1e-6 &&
                  console.warn(
                    "ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when raycasting."
                  );
              let t = { distance: 1 / 0, tile: null };
              n.push(t),
                (t.distance = R.distanceToSquared(U.origin) * e * e),
                (t.tile = r);
            }
          }
        }
        n.sort(k);
        let o = 1 / 0,
          a = null;
        for (let e = 0, i = n.length; e < i; e++) {
          const i = n[e];
          if (i.distance > o) break;
          {
            const e = i.tile,
              n = e.cached.scene;
            let l = null;
            if (
              (r.has(e)
                ? (O(n, s, P),
                  P.length > 0 && (P.length > 1 && P.sort(k), (l = P[0])))
                : (l = F(e, t, r, s)),
              l)
            ) {
              const e = l.distance * l.distance;
              e < o && ((o = e), (a = l)), (P.length = 0);
            }
          }
        }
        return a;
      }
      function I(e, t, r, s, n) {
        const i = e.cached,
          o = t.matrixWorld;
        E.copy(o);
        const a = i.sphere;
        if (a && (A.copy(a), A.applyMatrix4(E), !s.ray.intersectsSphere(A)))
          return;
        const l = i.box,
          c = i.boxTransform;
        if (
          l &&
          (E.multiply(c).invert(),
          U.copy(s.ray).applyMatrix4(E),
          !U.intersectsBox(l))
        )
          return;
        const h = i.scene;
        if (r.has(e)) return void O(h, s, n);
        const u = e.children;
        for (let e = 0, i = u.length; e < i; e++) I(u[e], t, r, s, n);
      }
      const V = Symbol("INITIAL_FRUSTUM_CULLED"),
        N = (b.Math.DEG2RAD, new b.Matrix4()),
        B = new b.Matrix4(),
        G = new b.Vector3(),
        z = new b.Vector3(),
        H = new b.Vector3(),
        $ = new b.Vector3(),
        W = new b.Vector3(1, 0, 0),
        j = new b.Vector3(0, 1, 0);
      function J(e, t) {
        e.traverse((e) => {
          e.frustumCulled = e[V] && t;
        });
      }
      class TilesRenderer extends class TilesRendererBase {
        get rootTileSet() {
          const e = this.tileSets[this.rootURL];
          return !e || e instanceof Promise ? null : e;
        }
        get root() {
          const e = this.rootTileSet;
          return e ? e.root : null;
        }
        constructor(e) {
          (this.tileSets = {}),
            (this.rootURL = e),
            (this.fetchOptions = {}),
            (this.preprocessURL = null);
          const t = new LRUCache();
          t.unloadPriorityCallback = g;
          const r = new PriorityQueue();
          (r.maxJobs = 4), (r.priorityCallback = m);
          const s = new PriorityQueue();
          (s.maxJobs = 1),
            (s.priorityCallback = m),
            (this.lruCache = t),
            (this.downloadQueue = r),
            (this.parseQueue = s),
            (this.stats = {
              parsing: 0,
              downloading: 0,
              failed: 0,
              inFrustum: 0,
              used: 0,
              active: 0,
              visible: 0,
            }),
            (this.frameCount = 0),
            (this.errorTarget = 6),
            (this.errorThreshold = 1 / 0),
            (this.loadSiblings = !0),
            (this.displayActiveTiles = !1),
            (this.maxDepth = 1 / 0),
            (this.stopAtEmptyTiles = !0);
        }
        traverse(e, t) {
          const r = this.tileSets[this.rootURL];
          r && r.root && h(r.root, e, t);
        }
        update() {
          const e = this.stats,
            t = this.lruCache,
            r = this.tileSets,
            s = r[this.rootURL];
          if (!(this.rootURL in r))
            return void this.loadRootTileSet(this.rootURL);
          if (!s || !s.root) return;
          const n = s.root;
          (e.inFrustum = 0),
            (e.used = 0),
            (e.active = 0),
            (e.visible = 0),
            this.frameCount++,
            u(n, this),
            d(n, this),
            p(n, this),
            f(n, this),
            t.scheduleUnload();
        }
        parseTile(e, t, r) {
          return null;
        }
        disposeTile(e) {}
        preprocessNode(e, t, r) {
          e.content &&
            (!("uri" in e.content) &&
              "url" in e.content &&
              ((e.content.uri = e.content.url), delete e.content.url),
            e.content.uri &&
              (e.content.uri = (function (...e) {
                const t = /^[a-zA-Z]+:\/\//;
                let r = -1;
                for (let s = 0, n = e.length; s < n; s++)
                  t.test(e[s]) && (r = s);
                if (-1 === r) return s.join(...e).replace(/\\/g, "/");
                {
                  const n = r <= 0 ? e : e.slice(r),
                    i = n[0].match(t)[0];
                  return (
                    (n[0] = n[0].substring(i.length)),
                    (i + s.join(...n)).replace(/\\/g, "/")
                  );
                }
              })(r, e.content.uri)),
            e.content.boundingVolume &&
              !(
                "box" in e.content.boundingVolume ||
                "sphere" in e.content.boundingVolume ||
                "region" in e.content.boundingVolume
              ) &&
              delete e.content.boundingVolume),
            (e.parent = t),
            (e.children = e.children || []);
          if (e.content && e.content.uri) {
            const t = /\.json$/i.test(e.content.uri);
            (e.__externalTileSet = t), (e.__contentEmpty = t);
          } else (e.__externalTileSet = !1), (e.__contentEmpty = !0);
          (e.__distanceFromCamera = 1 / 0),
            (e.__error = 1 / 0),
            (e.__inFrustum = !1),
            (e.__isLeaf = !1),
            (e.__usedLastFrame = !1),
            (e.__used = !1),
            (e.__wasSetVisible = !1),
            (e.__visible = !1),
            (e.__childrenWereVisible = !1),
            (e.__allChildrenLoaded = !1),
            (e.__wasSetActive = !1),
            (e.__active = !1),
            (e.__loadingState = n.Jk),
            (e.__loadIndex = 0),
            (e.__loadAbort = null),
            (e.__depthFromRenderedParent = -1),
            null === t
              ? ((e.__depth = 0), (e.refine = e.refine || "REPLACE"))
              : ((e.__depth = t.__depth + 1),
                (e.refine = e.refine || t.refine));
        }
        setTileActive(e, t) {}
        setTileVisible(e, t) {}
        calculateError(e) {
          return 0;
        }
        tileInView(e) {
          return !0;
        }
        fetchTileSet(e, t, r = null) {
          return fetch(e, t)
            .then((t) => {
              if (t.ok) return t.json();
              throw new Error(
                `TilesRenderer: Failed to load tileset "${e}" with status ${t.status} : ${t.statusText}`
              );
            })
            .then((t) => {
              const n = t.asset.version;
              console.assert(
                "1.0" === n || "0.0" === n || "1.1" === n,
                'asset.version is expected to be a string of "1.0" or "0.0"'
              );
              const i = s.dirname(e);
              return (
                h(
                  t.root,
                  (e, t) => this.preprocessNode(e, t, i),
                  null,
                  r,
                  r ? r.__depth : 0
                ),
                t
              );
            });
        }
        loadRootTileSet(e) {
          const t = this.tileSets;
          if (e in t)
            return t[e] instanceof Error
              ? Promise.reject(t[e])
              : Promise.resolve(t[e]);
          {
            const r = this.fetchTileSet(e, this.fetchOptions).then((r) => {
              t[e] = r;
            });
            return (
              r.catch((r) => {
                console.error(r), (t[e] = r);
              }),
              (t[e] = r),
              r
            );
          }
        }
        requestTileContents(e) {
          if (e.__loadingState !== n.Jk) return;
          const t = this.stats,
            r = this.lruCache,
            s = this.downloadQueue,
            i = this.parseQueue,
            o = e.__externalTileSet;
          r.add(e, (e) => {
            e.__loadingState === n.br
              ? (e.__loadAbort.abort(), (e.__loadAbort = null))
              : o
              ? (e.children.length = 0)
              : this.disposeTile(e),
              e.__loadingState === n.br
                ? t.downloading--
                : e.__loadingState === n.yX && t.parsing--,
              (e.__loadingState = n.Jk),
              e.__loadIndex++,
              i.remove(e),
              s.remove(e);
          }),
            e.__loadIndex++;
          const a = e.__loadIndex,
            l = new AbortController(),
            c = l.signal;
          t.downloading++, (e.__loadAbort = l), (e.__loadingState = n.br);
          const h = (o) => {
            e.__loadIndex === a &&
              ("AbortError" !== o.name
                ? (i.remove(e),
                  s.remove(e),
                  e.__loadingState === n.yX
                    ? t.parsing--
                    : e.__loadingState === n.br && t.downloading--,
                  t.failed++,
                  console.error(
                    `TilesRenderer : Failed to load tile at url "${e.content.uri}".`
                  ),
                  console.error(o),
                  (e.__loadingState = n.ig))
                : r.remove(e));
          };
          o
            ? s
                .add(e, (e) => {
                  if (e.__loadIndex !== a) return Promise.resolve();
                  const t = this.preprocessURL
                    ? this.preprocessURL(e.content.uri)
                    : e.content.uri;
                  return this.fetchTileSet(
                    t,
                    Object.assign({ signal: c }, this.fetchOptions),
                    e
                  );
                })
                .then((r) => {
                  e.__loadIndex === a &&
                    (t.downloading--,
                    (e.__loadAbort = null),
                    (e.__loadingState = n.tE),
                    e.children.push(r.root));
                })
                .catch(h)
            : s
                .add(e, (e) => {
                  if (e.__loadIndex !== a) return Promise.resolve();
                  const t = this.preprocessURL
                    ? this.preprocessURL(e.content.uri)
                    : e.content.uri;
                  return fetch(
                    t,
                    Object.assign({ signal: c }, this.fetchOptions)
                  );
                })
                .then((t) => {
                  if (e.__loadIndex === a) {
                    if (t.ok) return t.arrayBuffer();
                    throw new Error(
                      `Failed to load model with error code ${t.status}`
                    );
                  }
                })
                .then((r) => {
                  if (e.__loadIndex === a)
                    return (
                      t.downloading--,
                      t.parsing++,
                      (e.__loadAbort = null),
                      (e.__loadingState = n.yX),
                      i.add(e, (e) => {
                        if (e.__loadIndex !== a) return Promise.resolve();
                        const t = e.content.uri.split(/\./g).pop();
                        return this.parseTile(r, e, t);
                      })
                    );
                })
                .then(() => {
                  e.__loadIndex === a &&
                    (t.parsing--,
                    (e.__loadingState = n.tE),
                    e.__wasSetVisible && this.setTileVisible(e, !0),
                    e.__wasSetActive && this.setTileActive(e, !0));
                })
                .catch(h);
        }
        dispose() {
          const e = this.lruCache;
          this.traverse((t) => {
            e.remove(t);
          });
        }
      } {
        get autoDisableRendererCulling() {
          return this._autoDisableRendererCulling;
        }
        set autoDisableRendererCulling(e) {
          this._autoDisableRendererCulling !== e &&
            ((super._autoDisableRendererCulling = e),
            this.forEachLoadedModel((t) => {
              J(t, !e);
            }));
        }
        constructor(...e) {
          super(...e),
            (this.group = new TilesGroup(this)),
            (this.cameras = []),
            (this.cameraMap = new Map()),
            (this.cameraInfo = []),
            (this.activeTiles = new Set()),
            (this.visibleTiles = new Set()),
            (this._autoDisableRendererCulling = !0),
            (this.optimizeRaycast = !0),
            (this.onLoadTileSet = null),
            (this.onLoadModel = null),
            (this.onDisposeModel = null),
            (this.tileContentParsers = new Map());
          const t = new b.LoadingManager();
          t.setURLModifier((e) =>
            this.preprocessURL ? this.preprocessURL(e) : e
          ),
            (this.manager = t);
          const r = this;
          (this._overridenRaycast = function (e, t) {
            r.optimizeRaycast ||
              Object.getPrototypeOf(this).raycast.call(this, e, t);
          }),
            this.registerTileContentParser("b3dm", B3DMLoader),
            this.registerTileContentParser("i3dm", I3DMLoader),
            this.registerTileContentParser("cmpt", CMPTLoader),
            this.registerTileContentParser("gltf", CustomTileParser),
            this.registerTileContentParser("glb", CustomTileParser);
        }
        getBounds(e) {
          if (!this.root) return !1;
          const t = this.root.cached,
            r = t.box,
            s = t.boxTransform;
          return !!r && (e.copy(r), e.applyMatrix4(s), !0);
        }
        getOrientedBounds(e, t) {
          if (!this.root) return !1;
          const r = this.root.cached,
            s = r.box,
            n = r.boxTransform;
          return !!s && (e.copy(s), t.copy(n), !0);
        }
        getBoundingSphere(e) {
          if (!this.root) return !1;
          const t = this.root.cached.sphere;
          return !!t && (e.copy(t), !0);
        }
        forEachLoadedModel(e) {
          this.traverse((t) => {
            const r = t.cached.scene;
            r && e(r, t);
          });
        }
        raycast(e, t) {
          if (this.root)
            if (e.firstHitOnly) {
              const r = F(this.root, this.group, this.activeTiles, e);
              r && t.push(r);
            } else I(this.root, this.group, this.activeTiles, e, t);
        }
        hasCamera(e) {
          return this.cameraMap.has(e);
        }
        setCamera(e) {
          const t = this.cameras,
            r = this.cameraMap;
          return !r.has(e) && (r.set(e, new b.Vector2()), t.push(e), !0);
        }
        setResolution(e, t, r) {
          const s = this.cameraMap;
          return (
            !!s.has(e) &&
            (t instanceof b.Vector2 ? s.get(e).copy(t) : s.get(e).set(t, r), !0)
          );
        }
        setResolutionFromRenderer(e, t) {
          const r = this.cameraMap;
          if (!r.has(e)) return !1;
          const s = r.get(e);
          return t.getSize(s), s.multiplyScalar(t.getPixelRatio()), !0;
        }
        deleteCamera(e) {
          const t = this.cameras,
            r = this.cameraMap;
          if (r.has(e)) {
            const s = t.indexOf(e);
            return t.splice(s, 1), r.delete(e), !0;
          }
          return !1;
        }
        fetchTileSet(e, ...t) {
          const r = super.fetchTileSet(e, ...t);
          return (
            r.then((t) => {
              this.onLoadTileSet &&
                Promise.resolve().then(() => {
                  this.onLoadTileSet(t, e);
                });
            }),
            r
          );
        }
        update() {
          const e = this.group,
            t = this.cameras,
            r = this.cameraMap,
            s = this.cameraInfo;
          if (0 === t.length)
            return void console.warn(
              "TilesRenderer: no cameras defined. Cannot update 3d tiles."
            );
          for (; s.length > t.length; ) s.pop();
          for (; s.length < t.length; )
            s.push({
              frustum: new b.Frustum(),
              isOrthographic: !1,
              sseDenominator: -1,
              position: new b.Vector3(),
              invScale: -1,
              pixelSize: 0,
            });
          let n;
          B.copy(e.matrixWorld).invert(),
            G.setFromMatrixScale(B),
            (n = G.x),
            Math.abs(Math.max(G.x - G.y, G.x - G.z)) > 1e-6 &&
              console.warn(
                "ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error."
              );
          for (let i = 0, o = s.length; i < o; i++) {
            const o = t[i],
              a = s[i],
              l = a.frustum,
              c = a.position,
              h = r.get(o);
            (0 !== h.width && 0 !== h.height) ||
              console.warn(
                "TilesRenderer: resolution for camera error calculation is not set."
              );
            const u = o.projectionMatrix.elements;
            if (((a.isOrthographic = 1 === u[15]), a.isOrthographic)) {
              const e = 2 / u[0],
                t = 2 / u[5];
              a.pixelSize = Math.max(t / h.height, e / h.width);
            } else a.sseDenominator = 2 / u[5] / h.height;
            (a.invScale = n),
              N.copy(e.matrixWorld),
              N.premultiply(o.matrixWorldInverse),
              N.premultiply(o.projectionMatrix),
              l.setFromProjectionMatrix(N),
              c.set(0, 0, 0),
              c.applyMatrix4(o.matrixWorld),
              c.applyMatrix4(B);
          }
          super.update();
        }
        preprocessNode(e, t, r) {
          super.preprocessNode(e, t, r);
          const s = new b.Matrix4();
          if (e.transform) {
            const t = e.transform;
            for (let e = 0; e < 16; e++) s.elements[e] = t[e];
          } else s.identity();
          t && s.premultiply(t.cached.transform);
          const n = new b.Matrix4().copy(s).invert();
          let i = null,
            o = null,
            a = null;
          if ("box" in e.boundingVolume) {
            const t = e.boundingVolume.box;
            (i = new b.Box3()),
              (o = new b.Matrix4()),
              (a = new b.Matrix4()),
              z.set(t[3], t[4], t[5]),
              H.set(t[6], t[7], t[8]),
              $.set(t[9], t[10], t[11]);
            const r = z.length(),
              n = H.length(),
              l = $.length();
            z.normalize(),
              H.normalize(),
              $.normalize(),
              0 === r && z.crossVectors(H, $),
              0 === n && H.crossVectors(z, $),
              0 === l && $.crossVectors(z, H),
              o.set(
                z.x,
                H.x,
                $.x,
                t[0],
                z.y,
                H.y,
                $.y,
                t[1],
                z.z,
                H.z,
                $.z,
                t[2],
                0,
                0,
                0,
                1
              ),
              o.premultiply(s),
              a.copy(o).invert(),
              i.min.set(-r, -n, -l),
              i.max.set(r, n, l);
          }
          let l = null;
          if ("sphere" in e.boundingVolume) {
            const t = e.boundingVolume.sphere;
            (l = new b.Sphere()),
              l.center.set(t[0], t[1], t[2]),
              (l.radius = t[3]),
              l.applyMatrix4(s);
          } else if ("box" in e.boundingVolume) {
            const t = e.boundingVolume.box;
            (l = new b.Sphere()),
              i.getBoundingSphere(l),
              l.center.set(t[0], t[1], t[2]),
              l.applyMatrix4(s);
          }
          "region" in e.boundingVolume &&
            console.warn(
              "ThreeTilesRenderer: region bounding volume not supported."
            ),
            (e.cached = {
              loadIndex: 0,
              transform: s,
              transformInverse: n,
              active: !1,
              inFrustum: [],
              box: i,
              boxTransform: o,
              boxTransformInverse: a,
              sphere: l,
              region: null,
              scene: null,
              geometry: null,
              material: null,
            });
        }
        registerTileContentParser(e, t) {
          this.tileContentParsers.has(e)
            ? console.warn(
                `TilesRenderer: Content type "${e}" already registered.`
              )
            : this.tileContentParsers.set(e, t);
        }
        parseTile(e, t, r) {
          (t._loadIndex = t._loadIndex || 0), t._loadIndex++;
          const s = t.content.uri.split(/[\\\/]/g);
          s.pop();
          const n = s.join("/"),
            i = this.fetchOptions,
            o = this.tileContentParsers,
            a = this.manager,
            l = t._loadIndex;
          let c = null;
          if (o.has(r)) {
            const t = new (o.get(r))(a, r);
            (t.workingPath = n),
              (t.fetchOptions = i),
              (c = t.parse(e).then((e) => e.scene));
          } else
            switch (r) {
              case "pnts":
                c = Promise.resolve(new PNTSLoader(a).parse(e).scene);
                break;
              default:
                console.warn(
                  `TilesRenderer: Content type "${r}" not supported.`
                ),
                  (c = Promise.resolve(null));
            }
          return c.then((e) => {
            if (t._loadIndex !== l) return;
            const s =
                (this.rootTileSet.asset && this.rootTileSet.asset.gltfUpAxis) ||
                "y",
              n = t.cached,
              i = n.transform;
            switch (s.toLowerCase()) {
              case "x":
                N.makeRotationAxis(j, -Math.PI / 2);
                break;
              case "y":
                N.makeRotationAxis(W, Math.PI / 2);
                break;
              case "z":
                N.identity();
            }
            e.updateMatrix(),
              "pnts" !== r && e.matrix.multiply(N),
              e.matrix.premultiply(i),
              e.matrix.decompose(e.position, e.quaternion, e.scale),
              e.traverse((e) => {
                e[V] = e.frustumCulled;
              }),
              J(e, !this.autoDisableRendererCulling),
              (n.scene = e),
              e.traverse((e) => {
                e.raycast = this._overridenRaycast;
              });
            const o = [],
              a = [],
              c = [];
            e.traverse((e) => {
              if ((e.geometry && a.push(e.geometry), e.material)) {
                const t = e.material;
                o.push(e.material);
                for (const e in t) {
                  const r = t[e];
                  r && r.isTexture && c.push(r);
                }
              }
            }),
              (n.materials = o),
              (n.geometry = a),
              (n.textures = c),
              this.onLoadModel && this.onLoadModel(e, t);
          });
        }
        disposeTile(e) {
          const t = e.cached;
          if (t.scene) {
            const r = t.materials,
              s = t.geometry,
              n = t.textures;
            for (let e = 0, t = s.length; e < t; e++) s[e].dispose();
            for (let e = 0, t = r.length; e < t; e++) r[e].dispose();
            for (let e = 0, t = n.length; e < t; e++) {
              n[e].dispose();
            }
            this.onDisposeModel && this.onDisposeModel(t.scene, e),
              (t.scene = null),
              (t.materials = null),
              (t.textures = null),
              (t.geometry = null);
          }
          e._loadIndex++;
        }
        setTileVisible(e, t) {
          const r = e.cached.scene,
            s = this.visibleTiles,
            n = this.group;
          t
            ? (n.add(r), s.add(e), r.updateMatrixWorld(!0))
            : (n.remove(r), s.delete(e));
        }
        setTileActive(e, t) {
          const r = this.activeTiles;
          t ? r.add(e) : r.delete(e);
        }
        calculateError(e) {
          const t = e.cached,
            r = t.inFrustum,
            s = this.cameras,
            n = this.cameraInfo,
            i = e.boundingVolume;
          if ("box" in i || "sphere" in i) {
            const i = t.sphere,
              o = t.box,
              a = t.boxTransformInverse,
              l = t.transformInverse,
              c = o && a;
            let h = -1 / 0,
              u = 1 / 0;
            for (let t = 0, d = s.length; t < d; t++) {
              if (!r[t]) continue;
              const s = n[t],
                d = s.invScale;
              let p;
              if (s.isOrthographic) {
                const t = s.pixelSize;
                p = e.geometricError / (t * d);
              } else {
                let t;
                G.copy(s.position),
                  c
                    ? (G.applyMatrix4(a), (t = o.distanceToPoint(G)))
                    : (G.applyMatrix4(l),
                      (t = Math.max(i.distanceToPoint(G), 0)));
                const r = t * d,
                  n = s.sseDenominator;
                (p = e.geometricError / (r * n)), (u = Math.min(u, r));
              }
              h = Math.max(h, p);
            }
            (e.__distanceFromCamera = u), (e.__error = h);
          } else
            "region" in i &&
              console.warn("ThreeTilesRenderer : Region bounds not supported.");
        }
        tileInView(e) {
          const t = e.cached,
            r = t.sphere,
            s = t.inFrustum;
          if (r) {
            const e = this.cameraInfo;
            let t = !1;
            for (let n = 0, i = e.length; n < i; n++) {
              e[n].frustum.intersectsSphere(r)
                ? ((t = !0), (s[n] = !0))
                : (s[n] = !1);
            }
            return t;
          }
          return !0;
        }
      }
    },
    26470: (e) => {
      "use strict";
      function t(e) {
        if ("string" != typeof e)
          throw new TypeError(
            "Path must be a string. Received " + JSON.stringify(e)
          );
      }
      function r(e, t) {
        for (var r, s = "", n = 0, i = -1, o = 0, a = 0; a <= e.length; ++a) {
          if (a < e.length) r = e.charCodeAt(a);
          else {
            if (47 === r) break;
            r = 47;
          }
          if (47 === r) {
            if (i === a - 1 || 1 === o);
            else if (i !== a - 1 && 2 === o) {
              if (
                s.length < 2 ||
                2 !== n ||
                46 !== s.charCodeAt(s.length - 1) ||
                46 !== s.charCodeAt(s.length - 2)
              )
                if (s.length > 2) {
                  var l = s.lastIndexOf("/");
                  if (l !== s.length - 1) {
                    -1 === l
                      ? ((s = ""), (n = 0))
                      : (n =
                          (s = s.slice(0, l)).length - 1 - s.lastIndexOf("/")),
                      (i = a),
                      (o = 0);
                    continue;
                  }
                } else if (2 === s.length || 1 === s.length) {
                  (s = ""), (n = 0), (i = a), (o = 0);
                  continue;
                }
              t && (s.length > 0 ? (s += "/..") : (s = ".."), (n = 2));
            } else
              s.length > 0
                ? (s += "/" + e.slice(i + 1, a))
                : (s = e.slice(i + 1, a)),
                (n = a - i - 1);
            (i = a), (o = 0);
          } else 46 === r && -1 !== o ? ++o : (o = -1);
        }
        return s;
      }
      var s = {
        resolve: function () {
          for (
            var e, s = "", n = !1, i = arguments.length - 1;
            i >= -1 && !n;
            i--
          ) {
            var o;
            i >= 0
              ? (o = arguments[i])
              : (void 0 === e && (e = process.cwd()), (o = e)),
              t(o),
              0 !== o.length &&
                ((s = o + "/" + s), (n = 47 === o.charCodeAt(0)));
          }
          return (
            (s = r(s, !n)),
            n ? (s.length > 0 ? "/" + s : "/") : s.length > 0 ? s : "."
          );
        },
        normalize: function (e) {
          if ((t(e), 0 === e.length)) return ".";
          var s = 47 === e.charCodeAt(0),
            n = 47 === e.charCodeAt(e.length - 1);
          return (
            0 !== (e = r(e, !s)).length || s || (e = "."),
            e.length > 0 && n && (e += "/"),
            s ? "/" + e : e
          );
        },
        isAbsolute: function (e) {
          return t(e), e.length > 0 && 47 === e.charCodeAt(0);
        },
        join: function () {
          if (0 === arguments.length) return ".";
          for (var e, r = 0; r < arguments.length; ++r) {
            var n = arguments[r];
            t(n), n.length > 0 && (void 0 === e ? (e = n) : (e += "/" + n));
          }
          return void 0 === e ? "." : s.normalize(e);
        },
        relative: function (e, r) {
          if ((t(e), t(r), e === r)) return "";
          if ((e = s.resolve(e)) === (r = s.resolve(r))) return "";
          for (var n = 1; n < e.length && 47 === e.charCodeAt(n); ++n);
          for (
            var i = e.length, o = i - n, a = 1;
            a < r.length && 47 === r.charCodeAt(a);
            ++a
          );
          for (
            var l = r.length - a, c = o < l ? o : l, h = -1, u = 0;
            u <= c;
            ++u
          ) {
            if (u === c) {
              if (l > c) {
                if (47 === r.charCodeAt(a + u)) return r.slice(a + u + 1);
                if (0 === u) return r.slice(a + u);
              } else
                o > c &&
                  (47 === e.charCodeAt(n + u) ? (h = u) : 0 === u && (h = 0));
              break;
            }
            var d = e.charCodeAt(n + u);
            if (d !== r.charCodeAt(a + u)) break;
            47 === d && (h = u);
          }
          var p = "";
          for (u = n + h + 1; u <= i; ++u)
            (u !== i && 47 !== e.charCodeAt(u)) ||
              (0 === p.length ? (p += "..") : (p += "/.."));
          return p.length > 0
            ? p + r.slice(a + h)
            : ((a += h), 47 === r.charCodeAt(a) && ++a, r.slice(a));
        },
        _makeLong: function (e) {
          return e;
        },
        dirname: function (e) {
          if ((t(e), 0 === e.length)) return ".";
          for (
            var r = e.charCodeAt(0),
              s = 47 === r,
              n = -1,
              i = !0,
              o = e.length - 1;
            o >= 1;
            --o
          )
            if (47 === (r = e.charCodeAt(o))) {
              if (!i) {
                n = o;
                break;
              }
            } else i = !1;
          return -1 === n
            ? s
              ? "/"
              : "."
            : s && 1 === n
            ? "//"
            : e.slice(0, n);
        },
        basename: function (e, r) {
          if (void 0 !== r && "string" != typeof r)
            throw new TypeError('"ext" argument must be a string');
          t(e);
          var s,
            n = 0,
            i = -1,
            o = !0;
          if (void 0 !== r && r.length > 0 && r.length <= e.length) {
            if (r.length === e.length && r === e) return "";
            var a = r.length - 1,
              l = -1;
            for (s = e.length - 1; s >= 0; --s) {
              var c = e.charCodeAt(s);
              if (47 === c) {
                if (!o) {
                  n = s + 1;
                  break;
                }
              } else
                -1 === l && ((o = !1), (l = s + 1)),
                  a >= 0 &&
                    (c === r.charCodeAt(a)
                      ? -1 == --a && (i = s)
                      : ((a = -1), (i = l)));
            }
            return (
              n === i ? (i = l) : -1 === i && (i = e.length), e.slice(n, i)
            );
          }
          for (s = e.length - 1; s >= 0; --s)
            if (47 === e.charCodeAt(s)) {
              if (!o) {
                n = s + 1;
                break;
              }
            } else -1 === i && ((o = !1), (i = s + 1));
          return -1 === i ? "" : e.slice(n, i);
        },
        extname: function (e) {
          t(e);
          for (
            var r = -1, s = 0, n = -1, i = !0, o = 0, a = e.length - 1;
            a >= 0;
            --a
          ) {
            var l = e.charCodeAt(a);
            if (47 !== l)
              -1 === n && ((i = !1), (n = a + 1)),
                46 === l
                  ? -1 === r
                    ? (r = a)
                    : 1 !== o && (o = 1)
                  : -1 !== r && (o = -1);
            else if (!i) {
              s = a + 1;
              break;
            }
          }
          return -1 === r ||
            -1 === n ||
            0 === o ||
            (1 === o && r === n - 1 && r === s + 1)
            ? ""
            : e.slice(r, n);
        },
        format: function (e) {
          if (null === e || "object" != typeof e)
            throw new TypeError(
              'The "pathObject" argument must be of type Object. Received type ' +
                typeof e
            );
          return (function (e, t) {
            var r = t.dir || t.root,
              s = t.base || (t.name || "") + (t.ext || "");
            return r ? (r === t.root ? r + s : r + e + s) : s;
          })("/", e);
        },
        parse: function (e) {
          t(e);
          var r = { root: "", dir: "", base: "", ext: "", name: "" };
          if (0 === e.length) return r;
          var s,
            n = e.charCodeAt(0),
            i = 47 === n;
          i ? ((r.root = "/"), (s = 1)) : (s = 0);
          for (
            var o = -1, a = 0, l = -1, c = !0, h = e.length - 1, u = 0;
            h >= s;
            --h
          )
            if (47 !== (n = e.charCodeAt(h)))
              -1 === l && ((c = !1), (l = h + 1)),
                46 === n
                  ? -1 === o
                    ? (o = h)
                    : 1 !== u && (u = 1)
                  : -1 !== o && (u = -1);
            else if (!c) {
              a = h + 1;
              break;
            }
          return (
            -1 === o ||
            -1 === l ||
            0 === u ||
            (1 === u && o === l - 1 && o === a + 1)
              ? -1 !== l &&
                (r.base = r.name = 0 === a && i ? e.slice(1, l) : e.slice(a, l))
              : (0 === a && i
                  ? ((r.name = e.slice(1, o)), (r.base = e.slice(1, l)))
                  : ((r.name = e.slice(a, o)), (r.base = e.slice(a, l))),
                (r.ext = e.slice(o, l))),
            a > 0 ? (r.dir = e.slice(0, a - 1)) : i && (r.dir = "/"),
            r
          );
        },
        sep: "/",
        delimiter: ":",
        win32: null,
        posix: null,
      };
      (s.posix = s), (e.exports = s);
    },
  },
]);
